'use strict';
const Decimal = require('decimal.js');

class CalculateAmount {
  static calculate(train_type, site_count) {
    const PER_NORMAL_SPEED = 15.00;
    const PER_QUICK_SPEED = 25.00;
    let amount = 0;
    if (train_type === 'normal') {
      amount = new Decimal(PER_NORMAL_SPEED)
        .mul(new Decimal(site_count))
        .add(new Decimal(amount))
        .toNumber()
        .toFixed(2);
    } else {
      amount = new Decimal(PER_QUICK_SPEED)
        .mul(new Decimal(site_count))
        .add(new Decimal(amount))
        .toNumber()
        .toFixed(2);
    }
    return amount;
  }
}

module.exports = CalculateAmount;
